package com.kingstar.ceres.data.util;

import org.slf4j.helpers.MessageFormatter;

import java.text.MessageFormat;

/**
 * @author eric.wang
 *
 */
public abstract class MessageFormatUtils {

	public static final String format(String messagePattern, Object... args) {
		return arrayFormat(messagePattern, args);
	}

	static final String arrayFormat(String messagePattern, Object[] argArray) {
		return MessageFormatter.arrayFormat(messagePattern, argArray).getMessage();
	}

	public static String format(boolean slf4jFormat, String message, Object... args) {
		if (slf4jFormat) {
			return format(message, args);
		} else {
			return MessageFormat.format(message, args);
		}
	}
	
}
